<?php

class Message_Widget_Browse_Profile_Inbox extends Nuo_Widget
{
	function execute()
	{
		$table = Nuo::getTable('message');

		$itemTable = Nuo::getT('message_item');

		$mainResource = Nuo::getVar('mainResource');

		$select = $table -> select() 
		-> from(array('m' => $table -> getName())) 
		-> joinLeft(array('i' => $itemTable), 'i.message_id=m.message_id') 
		-> where('i.receiver_id=?', $mainResource -> getItemId()) 
		-> order('i.sended_at DESC');

		$paging = Nuo_Paging::factory($select);

		return $this -> render(array(
			'paging' => $paging,
			'resource' => $mainResource
		));
	}

}
